home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CURLPushButton 2.3 / CURLPushButton.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-21  |  10.4 KB  |  390 lines  |  [TEXT/CWIE]

  1. /*******************************************************************************\
  2. |                                                                                |
  3. | CURLPushButton.h     ©1997 John C. Daub.  All rights reserved                    |
  4. |                                                                                |
  5. | See the file "CURLPushButton README" for full details, instructions, changes, |
  6. | licensing agreement, etc.  Due to the important information included in that    |
  7. | file, if you did not receive a copy of it, please contact the author for        |
  8. | a copy.                                                                        |
  9. |                                                                                |
  10. | John C. Daub <mailto:hsoi@eden.com>                                            |
  11. | <http://www.eden.com/~hsoi/>  <http://www.eden.com/~hsoi/prog.html>            |
  12. |                                                                                |
  13. \*******************************************************************************/
  14.  
  15. #ifndef _H_CURLPushButton
  16. #define _H_CURLPushButton
  17.  
  18. #pragma once
  19.  
  20. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  21.     #pragma import on
  22. #endif
  23.  
  24. // Having this macro true will enhance CURLPushButton by giving it drag and
  25. // drop support. If you desire no such thing (and all the extra code it can
  26. // bring in), #define this to be false somewhere (e.g. prefix file) and all
  27. // the drag and drop code will be preprocessed out.
  28.  
  29. #ifndef _CURLPushButton_DO_DND_
  30. #define _CURLPushButton_DO_DND_            1
  31. #endif
  32.  
  33.  
  34. #include <PP_Prefix.h>
  35. #include <LControl.h>
  36. #include <LString.h>
  37.  
  38. // the following struct were created for and should only be
  39. // used for the parameterized constructor
  40.  
  41. #pragma options align=mac68k
  42.  
  43. typedef struct {
  44.     // following 4 are input params for an LControl
  45.     
  46.     MessageT        valueMessage;
  47.     Int32            value;
  48.     Int32            minValue;
  49.     Int32            maxValue;
  50.         
  51.     Str255            titleText;
  52.     ResIDT            textTraitsID;
  53.     
  54.     ResIDT            hiliteTextTraitsID;
  55.     Boolean            useHiliteColor;
  56.     RGBColor        hiliteColor;
  57.     Str255            URL;
  58.     
  59.     Boolean            useInvertRect;
  60.     
  61. } SURLpbInfo, *SURLpbInfoPtr, **SURLpbInfoHandle;
  62.  
  63. #pragma options align=reset
  64.  
  65.  
  66.  
  67. class CURLPushButton : public LControl {
  68.  
  69. public:
  70.  
  71.         enum { class_ID = 'URpb' };
  72.  
  73. #if ( __PowerPlant__ < 0x01608000 ) // version 1.6/CW11
  74.     static CURLPushButton*    CreateFromStream( LStream *inStream );
  75. #endif
  76.  
  77.                                 CURLPushButton();
  78.                                 CURLPushButton(const CURLPushButton &inOriginal );
  79.                                 CURLPushButton(const SPaneInfo        &inPaneInfo,
  80.                                                 const SURLpbInfo &inParamInfo );
  81.                                 CURLPushButton( LStream *inStream );
  82.         virtual                    ~CURLPushButton();
  83.         
  84.                 CURLPushButton&    operator=( const CURLPushButton &inOriginal );
  85.  
  86.         virtual    void            SetValue( Int32 inValue );
  87.         
  88.         virtual    StringPtr        GetURL();
  89.         virtual    StringPtr        GetURL( Str255 outURL ) const;
  90.         virtual    void            SetURL( ConstStr255Param inURL );
  91.  
  92.         virtual StringPtr        GetDescriptor();
  93.         virtual    StringPtr        GetDescriptor( Str255 outDescriptor ) const;
  94.         virtual    void            SetDescriptor( ConstStr255Param inDescriptor );
  95.  
  96.         virtual    Boolean            GetInvertRect() const;
  97.         virtual    void            SetInvertRect( const Boolean inUseInvert );
  98.         virtual    Boolean            GetUseInvertRect() const;
  99.         virtual    void            SetUseInvertRect( const Boolean inUseInvert );
  100.         
  101.         virtual    ResIDT            GetTextTraitsID() const;
  102.         virtual    void            SetTextTraitsID( const ResIDT inResID );
  103.  
  104.         virtual    ResIDT            GetHiliteTextTraitsID() const;
  105.         virtual    void            SetHiliteTextTraitsID( const ResIDT inResID );
  106.  
  107.         virtual Boolean            GetUseHiliteColor() const;
  108.         virtual void            SetUseHiliteColor( Boolean inUseHiliteColor );
  109.  
  110.         virtual    void            GetHiliteColor( RGBColor &outColor ) const;
  111.         virtual    void            SetHiliteColor( const RGBColor &inHiliteColor );
  112.         virtual    void            SetHiliteColor( const Uint8 inRed, 
  113.                                                 const Uint8 inGreen, const Uint8 inBlue );
  114.  
  115. #if _CURLPushButton_DO_DND_
  116.         virtual    Boolean            GetDoDragAndDrop() const;
  117.         virtual    void            SetDoDragAndDrop( const Boolean inDoDragAndDrop );
  118. #endif
  119.     
  120.         
  121. protected:
  122.  
  123. #if _CURLPushButton_DO_DND_
  124.         virtual    void            ClickSelf(const SMouseDownEvent &inMouseDown );
  125.         virtual    void            CreateDragEvent( const SMouseDownEvent &inMouseDown );
  126. #endif
  127.  
  128.         virtual    void            DrawSelf();
  129.  
  130.         virtual    void            ActivateSelf();
  131.         virtual    void            DeactivateSelf();
  132.         
  133.         virtual    void            HotSpotResult( Int16 inHotSpot );
  134.         virtual    void            HotSpotAction(
  135.                                         Int16    inHotSpot,
  136.                                         Boolean    inCurrInside,
  137.                                         Boolean    inPrevInside);
  138.  
  139.  
  140. private:
  141.         
  142.                 LStr255            mTitleText;
  143.                 ResIDT            mTextTraitsID;
  144.                 LStr255            mURL;
  145.                 ResIDT            mHiliteTextTraitsID;
  146.                 Boolean            mUseHiliteColor;
  147.                 RGBColor        mHiliteColor;
  148.                 Boolean            mUseInvertRect;
  149.  
  150. #if _CURLPushButton_DO_DND_                
  151.                 Boolean            mDoDragAndDrop;
  152. #endif
  153.  
  154. };
  155.  
  156.  
  157. //========================================================================
  158. //    ••• Inlines
  159. //========================================================================
  160.  
  161.  
  162. //========================================================================
  163. //    • GetTextTraitsID                            [public, virtual]
  164. //========================================================================
  165. //    Return the Txtr ResIDT
  166.  
  167. inline
  168. ResIDT
  169. CURLPushButton::GetTextTraitsID() const
  170. {
  171.     return mTextTraitsID;
  172. }
  173.  
  174.  
  175. //========================================================================
  176. //    • SetTextTraitsID                            [public, virtual]
  177. //========================================================================
  178. //    Set the text traits to the given ResIDT
  179.  
  180. inline
  181. void
  182. CURLPushButton::SetTextTraitsID(
  183.     const ResIDT inResIDT )
  184. {
  185.     mTextTraitsID = inResIDT;
  186. }
  187.  
  188.  
  189. //========================================================================
  190. //    • GetHiliteTextTraitsID                        [public, virtual]
  191. //========================================================================
  192. //    Return the Txtr ResIDT
  193.  
  194. inline
  195. ResIDT
  196. CURLPushButton::GetHiliteTextTraitsID() const
  197. {
  198.     return mHiliteTextTraitsID;
  199. }
  200.  
  201.  
  202. //========================================================================
  203. //    • SetHiliteTextTraitsID                        [public, virtual]
  204. //========================================================================
  205. //    Set the hilite text traits to the given ResIDT
  206.  
  207. inline
  208. void
  209. CURLPushButton::SetHiliteTextTraitsID(
  210.     const ResIDT inResIDT )
  211. {
  212.     mHiliteTextTraitsID = inResIDT;
  213. }
  214.  
  215.  
  216. //========================================================================
  217. //    • GetUseHiliteColor                            [public, virtual]
  218. //========================================================================
  219. //    Return true if using hilite color or false if not
  220.  
  221. inline
  222. Boolean
  223. CURLPushButton::GetUseHiliteColor() const
  224. {
  225.     return mUseHiliteColor;
  226. }
  227.  
  228.  
  229. //========================================================================
  230. //    • SetUseHiliteColor                            [public, virtual]
  231. //========================================================================
  232. //    Used to set if we should use the hilite color or not
  233.  
  234. inline
  235. void
  236. CURLPushButton::SetUseHiliteColor(
  237.     const Boolean inUseHiliteColor )
  238. {
  239.     mUseHiliteColor = inUseHiliteColor;
  240. }
  241.  
  242.  
  243. //========================================================================
  244. //    • GetHiliteColor                            [public, virtual]
  245. //========================================================================
  246. //    Return the hilite color
  247.  
  248. inline
  249. void
  250. CURLPushButton::GetHiliteColor( RGBColor &outColor ) const
  251. {
  252.     outColor.red = mHiliteColor.red;
  253.     outColor.green = mHiliteColor.green;
  254.     outColor.blue = mHiliteColor.blue;
  255. }
  256.  
  257.  
  258. //========================================================================
  259. //    • SetHiliteColor                            [public, virtual]
  260. //========================================================================
  261. //    Set the hilite color to the given RGBColor
  262.  
  263. inline
  264. void
  265. CURLPushButton::SetHiliteColor(
  266.     const RGBColor &inHiliteColor )
  267. {
  268.     mHiliteColor.red = inHiliteColor.red;
  269.     mHiliteColor.green = inHiliteColor.green;
  270.     mHiliteColor.blue = inHiliteColor.blue;
  271. }
  272.  
  273. //========================================================================
  274. //    • SetHiliteColor                            [public, virtual]
  275. //========================================================================
  276. //    Set the hilite color to the given red, green, and blue values
  277.  
  278. inline
  279. void
  280. CURLPushButton::SetHiliteColor(
  281.     const Uint8    inRed,
  282.     const Uint8 inGreen,
  283.     const Uint8 inBlue )
  284. {
  285.     mHiliteColor.red = inRed;
  286.     mHiliteColor.green = inGreen;
  287.     mHiliteColor.blue = inBlue;
  288. }
  289.  
  290.  
  291. //========================================================================
  292. //    • SetInvertRect                                [public, virtual]
  293. //========================================================================
  294. //    Used to modify the behavior of HotSpotAction.  If you want to use
  295. //    InvertRect to give the visual feedback, then this accessor routine
  296. //    will allow you to set the behavior as such
  297. //
  298. //    This name is obsolete. Please use SetUseInvertRect() instead.
  299.  
  300. inline
  301. void
  302. CURLPushButton::SetInvertRect(
  303.     const Boolean inUseInvert )
  304. {
  305.     mUseInvertRect = inUseInvert;
  306. }
  307.  
  308.  
  309. //========================================================================
  310. //    • GetInvertRect                                [public, virtual]
  311. //========================================================================
  312. //    Determine if this object is using InvertRect (or not) for its behavior
  313. //    in HotSpotAction.
  314. //
  315. //    This name is obsolete. Please use GetUseInvertRect() instead.
  316.  
  317. inline
  318. Boolean
  319. CURLPushButton::GetInvertRect() const
  320. {
  321.     return mUseInvertRect;
  322. }
  323.  
  324.  
  325. //========================================================================
  326. //    • GetUseInvertRect & SetUseInvertRect        [public, virtual]
  327. //========================================================================
  328. //    GetInvertRect and SetInvertRect existed for a long time, but don't
  329. //    conform to the method accessor naming convention. I'm leaving in the
  330. //    original routines for backwards compatability, but also adding these new
  331. //    named routines for consistancy with the naming convention.
  332. //
  333. //    Please use these methods for any new code.
  334.  
  335. inline
  336. void
  337. CURLPushButton::SetUseInvertRect(
  338.     const Boolean inUseInvert )
  339. {
  340.     mUseInvertRect = inUseInvert;
  341. }
  342.  
  343.  
  344. inline
  345. Boolean
  346. CURLPushButton::GetUseInvertRect() const
  347. {
  348.     return mUseInvertRect;
  349. }
  350.  
  351.  
  352. // these functions are only used if we are supporting drag and drop
  353.  
  354. #if _CURLPushButton_DO_DND_
  355.  
  356. //========================================================================
  357. //    • GetDoDragAndDrop                            [public, virtual]
  358. //========================================================================
  359. //    Return true if this object does drag and drop support
  360.  
  361. inline
  362. Boolean
  363. CURLPushButton::GetDoDragAndDrop() const
  364. {
  365.     return mDoDragAndDrop;
  366. }
  367.  
  368.  
  369. //========================================================================
  370. //    • SetDoDragAndDrop                            [public, virtual]
  371. //========================================================================
  372. //    Set if this object will support drag and drop or not
  373.  
  374. inline
  375. void
  376. CURLPushButton::SetDoDragAndDrop(
  377.     const Boolean inDoDragAndDrop )
  378. {
  379.     mDoDragAndDrop = inDoDragAndDrop;
  380. }
  381.  
  382. #endif // _CURLPushButton_DO_DND_
  383.  
  384.  
  385.  
  386. #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
  387.     #pragma import reset
  388. #endif
  389.  
  390. #endif /* _H_CURLPushButton */